package cn.iocoder.yudao.module.system.dal.mysql.noticeread;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.noticeread.NoticeReadDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.app.noticeread.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户通知公告阅读记录 Mapper
 *
 * @author lizhongwen
 */
@Mapper
public interface NoticeReadMapper extends BaseMapperX<NoticeReadDO> {

    default PageResult<NoticeReadDO> selectPage(AppNoticeReadPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NoticeReadDO>()
                .eqIfPresent(NoticeReadDO::getNoticeId, reqVO.getNoticeId())
                .eqIfPresent(NoticeReadDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(NoticeReadDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(NoticeReadDO::getId));
    }

    Integer selectUnreadNoticeCountByUserId(@Param("userId") Long userId,
                                            @Param("noticeStatus") Integer noticeStatus);

}